In [1]:
import tensorflow as tf
print(tf.__version__)
In [2]:
hello = tf.constant("Hello")
In [3]:
print(hello)
파이썬3 버전은 문자열(str) unicode가 기본이므로 str에서 encoding처리해 줘야 bytes 타입을 uncode type으로 변환함 안해줄 경우 b'Hello'이렇게 나옴
In [4]:
sess = tf.Session()
print(str(sess.run(hello),encoding = "utf-8"))
# print(sess.run(hello))
sess.close()
In [5]:
a = tf.constant(1234, dtype=tf.float32)
b = tf.constant(5000, dtype=tf.float32)
print(a)
print(b)
In [6]:
add_op = a + b
print(add_op)
In [7]:
with tf.Session() as sess:
print(sess.run(add_op))
In [8]:
add_op2 = tf.add(a,b)
with tf.Session() as sess:
print(sess.run(add_op2))
In [9]:
%matplotlib inline
In [10]:
import matplotlib.pyplot as plt
In [11]:
plt.hist([1,2,3])
plt.show()
In [12]:
import numpy as np
In [13]:
x = np.arange(-20,20,0.1)
In [14]:
y = np.sin(x)
In [15]:
plt.plot(x,y)
Out[15]:
In [16]:
a = tf.constant(100)
b = tf.constant(50)
In [17]:
add_op = a + b
In [18]:
v = tf.Variable(0)
let_op = tf.assign(v, add_op)
In [19]:
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
_, v_val = sess.run([let_op,v])
print(v_val)
In [ ]: